package com.rxyb.hongyu.gateway.controller;


import com.alibaba.fastjson.JSONObject;
import com.rxyb.hongyu.gateway.dto.HongYuReq;
import com.rxyb.hongyu.gateway.dto.HongYuRsp;
import com.rxyb.hongyu.gateway.enums.RspCodeForHongyu;
import com.rxyb.hongyu.service.ThirdHongyuPullService;
import com.rxyb.security.annotation.Inner;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 鸿宇推送 前端控制器
 * </p>
 *
 * @author DUYH
 * @since 2020-06-09
 */
@Slf4j
@RestController
@RequestMapping(value = "/hongyu/pull")
public class ThirdHongyuPullController {

    @Autowired
    private ThirdHongyuPullService thirdHongyuPullService;

    /**
     * @author duyh
     */
    @Inner
    @PostMapping(value = "F20C01")
    public String f20C01(@RequestBody String reqJson) {
        HongYuReq hongYuReq;
        HongYuRsp hongYuRsp;
        try {
            hongYuReq = JSONObject.parseObject(reqJson, HongYuReq.class);
            hongYuRsp = thirdHongyuPullService.f20C01(hongYuReq);
        } catch (Exception e) {
            hongYuRsp = new HongYuRsp();
            hongYuRsp.setRetcode(RspCodeForHongyu.FAILED.getCode());
            hongYuRsp.setRetmessage(RspCodeForHongyu.FAILED.getDesc());
        }
        return JSONObject.toJSONString(hongYuRsp);
    }

    /**
     * @author duyh
     */
    @Inner
    @PostMapping(value = "F20C02")
    public String f20C02(@RequestBody String reqJson) {
        HongYuReq hongYuReq;
        HongYuRsp hongYuRsp;
        try {
            hongYuReq = JSONObject.parseObject(reqJson, HongYuReq.class);
            hongYuRsp = thirdHongyuPullService.f20C02(hongYuReq);
        } catch (Exception e) {
            hongYuRsp = new HongYuRsp();
            hongYuRsp.setRetcode(RspCodeForHongyu.FAILED.getCode());
            hongYuRsp.setRetmessage(RspCodeForHongyu.FAILED.getDesc());
        }
        return JSONObject.toJSONString(hongYuRsp);
    }

    /**
     * @author duyh
     */
    @Inner
    @PostMapping(value = "F20C03")
    public String f20C03(@RequestBody String reqJson) {
        HongYuReq hongYuReq;
        HongYuRsp hongYuRsp;
        try {
            hongYuReq = JSONObject.parseObject(reqJson, HongYuReq.class);
            hongYuRsp = thirdHongyuPullService.f20C03(hongYuReq);
        } catch (Exception e) {
            hongYuRsp = new HongYuRsp();
            hongYuRsp.setRetcode(RspCodeForHongyu.FAILED.getCode());
            hongYuRsp.setRetmessage(RspCodeForHongyu.FAILED.getDesc());
        }
        return JSONObject.toJSONString(hongYuRsp);
    }

    /**
     * @author duyh
     */
    @Inner
    @PostMapping(value = "F20C04")
    public String f20C04(@RequestBody String reqJson) {
        HongYuReq hongYuReq;
        HongYuRsp hongYuRsp;
        try {
            hongYuReq = JSONObject.parseObject(reqJson, HongYuReq.class);
            hongYuRsp = thirdHongyuPullService.f20C04(hongYuReq);
        } catch (Exception e) {
            hongYuRsp = new HongYuRsp();
            hongYuRsp.setRetcode(RspCodeForHongyu.FAILED.getCode());
            hongYuRsp.setRetmessage(RspCodeForHongyu.FAILED.getDesc());
        }
        return JSONObject.toJSONString(hongYuRsp);
    }

    /**
     * @author duyh
     */
    @Inner
    @PostMapping(value = "F20C05")
    public String f20C05(@RequestBody String reqJson) {
        HongYuReq hongYuReq;
        HongYuRsp hongYuRsp;
        try {
            hongYuReq = JSONObject.parseObject(reqJson, HongYuReq.class);
            hongYuRsp = thirdHongyuPullService.f20C05(hongYuReq);
        } catch (Exception e) {
            hongYuRsp = new HongYuRsp();
            hongYuRsp.setRetcode(RspCodeForHongyu.FAILED.getCode());
            hongYuRsp.setRetmessage(RspCodeForHongyu.FAILED.getDesc());
        }
        return JSONObject.toJSONString(hongYuRsp);
    }

    /**
     * @author duyh
     */
    @Inner
    @PostMapping(value = "F20C06")
    public String f20C06(@RequestBody String reqJson) {
        HongYuReq hongYuReq;
        HongYuRsp hongYuRsp;
        try {
            hongYuReq = JSONObject.parseObject(reqJson, HongYuReq.class);
            hongYuRsp = thirdHongyuPullService.f20C06(hongYuReq);
        } catch (Exception e) {
            hongYuRsp = new HongYuRsp();
            hongYuRsp.setRetcode(RspCodeForHongyu.FAILED.getCode());
            hongYuRsp.setRetmessage(RspCodeForHongyu.FAILED.getDesc());
        }
        return JSONObject.toJSONString(hongYuRsp);
    }

    /**
     * @author duyh
     */
    @Inner
    @PostMapping(value = "F20C07")
    public String f20C07(@RequestBody String reqJson) {
        HongYuReq hongYuReq;
        HongYuRsp hongYuRsp;
        try {
            hongYuReq = JSONObject.parseObject(reqJson, HongYuReq.class);
            hongYuRsp = thirdHongyuPullService.f20C07(hongYuReq);
        } catch (Exception e) {
            hongYuRsp = new HongYuRsp();
            hongYuRsp.setRetcode(RspCodeForHongyu.FAILED.getCode());
            hongYuRsp.setRetmessage(RspCodeForHongyu.FAILED.getDesc());
        }
        return JSONObject.toJSONString(hongYuRsp);
    }

    /**
     * @author duyh
     */
    @Inner
    @PostMapping(value = "F20C08")
    public String f20C08(@RequestBody String reqJson) {
        HongYuReq hongYuReq;
        HongYuRsp hongYuRsp;
        try {
            hongYuReq = JSONObject.parseObject(reqJson, HongYuReq.class);
            hongYuRsp = thirdHongyuPullService.f20C08(hongYuReq);
        } catch (Exception e) {
            hongYuRsp = new HongYuRsp();
            hongYuRsp.setRetcode(RspCodeForHongyu.FAILED.getCode());
            hongYuRsp.setRetmessage(RspCodeForHongyu.FAILED.getDesc());
        }
        return JSONObject.toJSONString(hongYuRsp);
    }

}
